<?php

class Login extends Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {
        $this->view->error = false;
        $this->view->render('login/index');
    }
    
    public function signin()
    {
        if ( $this->model->signin())
        {
            header('location: ' . URL );
        }
        else 
        {
            $this->view->error = true;
            $this->view->render('login/index');
        }
    }
    
    public function logout()
    {
        Session::init();
        Session::destroy();
        header('location: ' . URL );
    }
    
    public function signup()
    {
         $this->view->render('login/signup');
    }
    
    public function create() 
    {
        $errors = $this->model->create();
       
        die();
        if ( count($errors) > 0)
        {
            $this->view->error = $errors;
            signup();
        }
        else
        {
            header('location: ' . URL);
        }
    }
}